package com.my.jfinal.handler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.SecurityUtils;

import com.jfinal.handler.Handler;
import com.jfinal.kit.HandlerKit;
import com.jfinal.kit.PropKit;

public class CommonHandler extends Handler {

	@Override
	public void handle(String target, HttpServletRequest request,
			HttpServletResponse response, boolean[] isHandled) {
		//如果没登录
		if(SecurityUtils.getSubject().getPrincipal()==null){
			HandlerKit.redirect(request.getContextPath()+PropKit.get("loginUrl"), request, response, isHandled);
		}
		next.handle(target, request, response, isHandled);

	}

}
